244B - Undoubtedly Lucky Numbers - CodeForces Solution


bitmasks brute force dfs and similar *1600

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#include <map>
using namespace std;
long long int ans;
int n, a, b;
std::map<int, int> S;
void DFS(long long int value, int length)
{
  if (value > n || length > 10)
    return;
  S[value]++;
  DFS(value * 10 + a, length + 1);
  DFS(value * 10 + b, length + 1);
}
int main()
{

  cin >> n;
  ans = 0;
  for (a = 0; a < 10; a++)
    for (b = a; b < 10; b++)
      DFS(0, 0);
  cout << S.size() - 1; // delete 0

  return 0;
}


Comments

Submit
0 Comments
More Questions

Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum